package com.company.woye.console.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.company.woye.R;
import com.company.woye.base.BaseActivity;
import com.company.woye.console.adapter.BoxOperationListviewAdapter;
import com.company.woye.console.adapter.SingleNumNumberListViewAdapter;
import com.company.woye.console.adapter.SingleNumberDetailListviewAdapter;
import com.company.woye.console.adapter.SingleNumberListviewAdapter;

import butterknife.BindView;
import butterknife.OnClick;

public class BoxOperationActivity extends BaseActivity {

    @BindView(R.id.lv_box_operation_summary)
    ListView summaryListView;

    @BindView(R.id.ll_box_operation_summary)
    LinearLayout summaryLinearLayout;

    @BindView(R.id.tv_box_operation_summary)
    TextView summaryTextView;

    @BindView(R.id.lv_box_operation_detail)
    ListView detailListView;

    @BindView(R.id.ll_box_operation_detail)
    LinearLayout detailLinearLayout;

    @BindView(R.id.tv_box_operation_detail)
    TextView detailTextView;

    @BindView(R.id.lv_box_operation_number)
    ListView numberListView;

    @BindView(R.id.ll_box_operation_number)
    LinearLayout numberLinearLayout;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int setLayoutId() {
        return R.layout.activity_box_operation;
    }

    @Override
    public void initView() {
        summaryListView.setAdapter(new BoxOperationListviewAdapter(this));
        detailListView.setOnItemClickListener((parent, view, position, id) -> {
            numberLinearLayout.setVisibility(View.VISIBLE);
            numberListView.setVisibility(View.VISIBLE);
            numberListView.setAdapter(new SingleNumNumberListViewAdapter(BoxOperationActivity.this));
        });
    }

    @OnClick({R.id.iv_box_operation_back,R.id.tv_box_operation_summary, R.id.tv_box_operation_detail})
    public void onViewClick(View view) {
        switch (view.getId()) {
            case R.id.iv_box_operation_back:
                finish();
                break;
            case R.id.tv_box_operation_summary:
                summaryTextViewOnClick();
                break;
            case R.id.tv_box_operation_detail:
                detailTextViewOnClick();
                break;
        }
    }

    private void summaryTextViewOnClick(){
        summaryLinearLayout.setVisibility(View.VISIBLE);
        detailLinearLayout.setVisibility(View.GONE);
        numberLinearLayout.setVisibility(View.GONE);
        numberListView.setVisibility(View.GONE);
        summaryListView.setAdapter(new SingleNumberListviewAdapter(this));
        summaryTextView.setTextColor(getResources().getColor(R.color.blue));
        detailTextView.setTextColor(getResources().getColor(R.color.darkGray));
    }


    private void detailTextViewOnClick(){
        summaryLinearLayout.setVisibility(View.GONE);
        detailListView.setAdapter(new SingleNumberDetailListviewAdapter(this));
        detailLinearLayout.setVisibility(View.VISIBLE);
        summaryTextView.setTextColor(getResources().getColor(R.color.darkGray));
        detailTextView.setTextColor(getResources().getColor(R.color.blue));
    }
}
